<?php echo $this->Html->css('frontend/styles'); ?>
<div id="wr_left">
    <?php echo $this->element('frontend/catelog'); ?>
    <?php echo $this->element('frontend/hot'); ?>
    <?php echo $this->element('frontend/new'); ?>       
    <div class="clear"></div>


</div>
<?php if(!empty($typeProducts)&& (!empty($products))){?>
<div id="wr_right">
    <div class="bg_dot">


        <div class="nav">
            <h2><a target="_self" href="#"><?php echo $typeProducts['TypeProduct']['type_name']?></a></h2>
        </div>
    </div>
    <?php echo $this->element("frontend/advert");?>
    <div class="product_listing">
        <div class="orderby">
            <?php if($this->params['paging']['Product']['pageCount'] > 1) {?>
            <div class="pager pager">
                    <?php
                   
                    echo "<ul>";
                     echo $this->Paginator->prev('  << ', null, null, array('tag' => 'span', 'class' => 'prev'));

                    echo $this->Paginator->numbers(array('modulus' => 4, "separator" => "&nbsp;", "tag" => "li", 'currentTag' => 'a', 'class' => 'paginate'));
                     echo $this->Paginator->next(' >>', null, null, array('tag' => 'span', 'class' => 'next'));
                  
                    echo "</ul>";
                    ?>

                </div>
            <?php } ?>
            <div class="sapxep">
                <span>Sắp xếp theo</span>
                <select class="drdOrder" id="orderProduct" onchange="">
                    <option value="1" <?php echo ($idOrder==1)?'selected="selected"':'' ?>>Giá giảm dần.</option>
                    <option value="2" <?php echo ($idOrder==2)?'selected="selected"':'' ?>>Giá tăng dần.</option>

                </select>
            </div>
        </div>
        <div class="list">
        <?php 
        $i=0;
        foreach ($products as $kProduct=>$vProduct){
        $i++;    
        ?>    
            <div class="item <?php echo ($i%4==0)?'last':''?>">

                <div class="wr_content">
                    <div class="wr_img">
                        <a href="<?php echo $this->Html->url("/products/detail/".$vProduct['Product']['id']);?>" rel="" title="" class="item-image" target="_self">
                            <img style="display:block;margin: 0 auto;width: 178px !important; height: 269px !important;" src="<?php echo $vProduct['Product']['image']; ?>" alt="<?php echo $vProduct['Product']['product_code']; ?>">
                        </a>
                       
                    </div>
                    <div class="title">
                        <a target="_self" href="<?php echo $this->Html->url("/products/detail/".$vProduct['Product']['id']);?>">
                            <?php echo $vProduct['Product']['product_name']; ?>
                        </a>
                    </div>
                    <div class="price">
                        <a target="_self" href="#">
                            <?php echo number_format($vProduct['Product']['price']); ?>VNĐ
                        </a>
                        
                        <?php if ($vProduct['Product']['type'] == 1) {
                            ?>
                            <img src="<?php echo $this->webroot . "img/frontend/" ?>icon_new.png" class="">
                        <?php } else if ($vProduct['Product']['type'] == 2) { ?>
                            <img src="<?php echo $this->webroot . "img/frontend/" ?>ishot.gif" class="">

                        <?php } ?>
                    </div>
                </div>
            </div>
        <?php }?>
            


            <div class="clear">
            </div>
        </div>

    </div>



</div>
<?php } ?>
<form method="post" action="#" id="frm" >
    <input type="hidden" value="" id="idOrder" name="order">
</form>
        
</form>
<script>
    $("#orderProduct").change(function(){
        var typeId='<?php echo $typeProducts['TypeProduct']['id']; ?>';
	var id=	$("#orderProduct").val();
		$("input#idOrder").val(id);
        $("#frm").attr("action","<?php echo $this->webroot ?>products/type_product/"+typeId+"/page:1");
        $("#frm").submit();
        });
    </script>

